/*
 * event.h
 */

#ifndef EVENT_H_
#define EVENT_H_

#include <stdarg.h>
#include <agent/unit.h>

typedef unsigned int event_t;

/*
 * The event struct.
 */
typedef struct {
    event_t type;
    void *info;
} event;

/*
 * The available types of events that can be expressed.
 */
enum event_types {
    move_event_type
    , attack_event_type
    , fly_event_type
    , land_event_type
    , damage_event_type
    , bleed_event_type
};

/*
 * Event structs
 */
typedef struct {
    long delta_x;
    long delta_y;
    unit *mover;
} move_event;

typedef struct {
    unsigned int amount;
    unit *victim;
} damage_event;

typedef struct {
    unit *flyer;
} fly_event;

typedef struct {
    unit *lander;
} land_event;

typedef struct {
    unsigned int amount;
    unit *victim;
} bleed_event;

typedef struct {
    unit *attacker;
    unit *victim;
    unsigned int amount;
} attack_event;

/*
 * Union to allow us to point to an event without specifying type
 */
union event_details {
    move_event *move;
    damage_event *damage;
    fly_event *fly;
    land_event *land;
    bleed_event *bleed;
};

/*
 * Frees the given event, freeing the event_details struct with it.
 */
void free_event(event *e);

typedef event *event_p;

#endif
